<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Screenshot Results</title>
    <style>
        :root {
            --bg-color: #f5f5f5;
            --container-bg: white;
            --text-color: #333;
            --border-color: #ddd;
            --info-bg: #e3f2fd;
            --info-border: #2196F3;
            --controls-bg: #f9f9f9;
            --input-bg: white;
            --shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        [data-theme="dark"] {
            --bg-color: #1a1a1a;
            --container-bg: #2d2d2d;
            --text-color: #e0e0e0;
            --border-color: #444;
            --info-bg: #1e3a5f;
            --info-border: #64b5f6;
            --controls-bg: #3a3a3a;
            --input-bg: #404040;
            --shadow: 0 2px 10px rgba(0,0,0,0.3);
        }
        
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: var(--bg-color);
            color: var(--text-color);
            transition: background-color 0.3s ease, color 0.3s ease;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background-color: var(--container-bg);
            border-radius: 8px;
            box-shadow: var(--shadow);
            overflow: hidden;
            transition: background-color 0.3s ease, box-shadow 0.3s ease;
        }
        .header {
            background-color: #4CAF50;
            color: white;
            padding: 20px;
            text-align: center;
            position: relative;
        }
        .header h1 {
            margin: 0;
            font-size: 24px;
        }
        .theme-toggle {
            position: absolute;
            top: 20px;
            right: 20px;
            background: none;
            border: 2px solid white;
            color: white;
            padding: 8px 12px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s ease;
        }
        .theme-toggle:hover {
            background-color: rgba(255, 255, 255, 0.1);
        }
        
        /* Language Toggle for Results Page */
        .language-toggle-result {
            position: absolute;
            top: 20px;
            right: 140px;
            background: rgba(255, 255, 255, 0.1);
            border: 2px solid white;
            color: white;
            padding: 8px 12px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            min-width: 80px;
            text-align: center;
        }
        
        .language-toggle-result:hover {
            background-color: rgba(255, 255, 255, 0.2);
            transform: translateY(-1px);
            box-shadow: 0 4px 8px rgba(0,0,0,0.15);
        }

        
        .content {
            padding: 20px;
        }
        
        .main-layout {
            display: flex;
            gap: 20px;
            align-items: flex-start;
        }
        
        .image-section {
            flex: 1;
            min-width: 0;
        }
        
        .sidebar {
            width: 300px;
            flex-shrink: 0;
        }
        
        @media (max-width: 768px) {
            .main-layout {
                flex-direction: column;
            }
            .sidebar {
                width: 100%;
            }
        }
        
        .image-container {
            text-align: center;
            margin-bottom: 20px;
            border: 2px dashed var(--border-color);
            padding: 20px;
            border-radius: 8px;
            transition: border-color 0.3s ease;
            position: relative;
        }
        
        /* Crop Section Styles */
        .crop-section {
            margin-bottom: 20px;
            padding: 15px;
            background-color: var(--controls-bg);
            border-radius: 8px;
            border: 1px solid var(--border-color);
            transition: all 0.3s ease;
        }
        
        .crop-section h3 {
            margin: 0 0 15px 0;
            color: var(--text-color);
            font-size: 16px;
        }
        
        .crop-controls-sidebar {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        .crop-tools {
            padding: 10px;
            background-color: var(--bg-color);
            border-radius: 6px;
            border: 1px solid var(--border-color);
        }
        
        .crop-info-sidebar {
            margin-bottom: 10px;
            padding: 8px;
            background-color: var(--info-bg);
            border-radius: 4px;
            border-left: 3px solid var(--info-border);
        }
        
        .button-group-vertical {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        
        .btn-small {
            padding: 8px 16px;
            font-size: 12px;
        }
        
        /* Crop selection styles for sidebar mode */
        .crop-active .image-container {
            border-color: #FF5722;
            border-style: solid;
        }
        
        .crop-selection-sidebar {
            position: absolute;
            border: 2px solid #FF5722;
            background-color: rgba(255, 87, 34, 0.1);
            cursor: move;
            min-width: 50px;
            min-height: 50px;
            top: 20%;
            left: 20%;
            width: 60%;
            height: 60%;
            box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
        }
        
        .screenshot {
            max-width: 100%;
            height: auto;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transition: border-color 0.3s ease;
        }
        .controls {
            background-color: var(--controls-bg);
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            transition: background-color 0.3s ease;
        }
        .form-group {
            margin-bottom: 15px;
        }
        .form-group label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
            color: var(--text-color);
            transition: color 0.3s ease;
        }
        .form-group input, .form-group select {
            width: 100%;
            padding: 10px;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-size: 14px;
            box-sizing: border-box;
            background-color: var(--input-bg);
            color: var(--text-color);
            transition: all 0.3s ease;
        }
        .form-group input:focus, .form-group select:focus {
            outline: none;
            border-color: #4CAF50;
            box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
        }
        .button-group {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        .btn {
            padding: 12px 24px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            font-weight: bold;
            text-decoration: none;
            display: inline-block;
            text-align: center;
            transition: background-color 0.3s;
        }
        .btn-primary {
            background-color: #4CAF50;
            color: white;
        }
        .btn-primary:hover {
            background-color: #45a049;
        }
        .btn-secondary {
            background-color: #2196F3;
            color: white;
        }
        .btn-secondary:hover {
            background-color: #1976D2;
        }
        .btn-info {
            background-color: #FF9800;
            color: white;
        }
        .btn-info:hover {
            background-color: #F57C00;
        }
        .info {
            background-color: var(--info-bg);
            border-left: 4px solid var(--info-border);
            padding: 15px;
            margin-bottom: 20px;
            border-radius: 4px;
            transition: all 0.3s ease;
        }
        .multiple-images {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }
        .image-item {
            border: 1px solid var(--border-color);
            border-radius: 8px;
            overflow: hidden;
            background-color: var(--container-bg);
            transition: all 0.3s ease;
        }
        .image-item img {
            width: 100%;
            height: auto;
            display: block;
        }
        .image-item .image-info {
            padding: 10px;
            background-color: var(--controls-bg);
            font-size: 12px;
            color: var(--text-color);
            transition: all 0.3s ease;
        }
        
        /* CSS cho chức năng crop - cập nhật cho dark mode */
        .crop-container {
            position: relative;
            display: inline-block;
            margin: 20px 0;
        }
        .crop-canvas {
            border: 2px solid #4CAF50;
            cursor: crosshair;
            max-width: 100%;
            height: auto;
            transition: border-color 0.3s ease;
        }
        .crop-canvas:hover {
            border-color: #FF5722;
            box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
        }
        [data-theme="dark"] .crop-canvas {
            border-color: #66BB6A;
        }
        [data-theme="dark"] .crop-canvas:hover {
            border-color: #FF7043;
            box-shadow: 0 0 15px rgba(102, 187, 106, 0.4);
        }
        [data-theme="dark"] .crop-overlay {
            box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.2);
        }
        [data-theme="dark"] .crop-overlay::before {
            border-color: rgba(255, 255, 255, 0.9);
        }
        .crop-overlay {
            position: absolute;
            border: 3px dashed #FF5722;
            background-color: rgba(255, 87, 34, 0.05);
            pointer-events: none;
            display: none;
            box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.1);
            transition: all 0.1s ease;
        }
        .crop-overlay::before {
            content: '';
            position: absolute;
            top: -3px;
            left: -3px;
            right: -3px;
            bottom: -3px;
            border: 2px solid rgba(255, 255, 255, 0.95);
            pointer-events: none;
            border-radius: 2px;
        }
        .crop-overlay::after {
            content: 'Vùng cắt';
            position: absolute;
            top: -35px;
            left: 0;
            background-color: #FF5722;
            color: white;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: bold;
            white-space: nowrap;
            pointer-events: none;
            box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        }
        .crop-controls {
            margin-top: 15px;
            text-align: center;
        }
        .crop-controls button {
            margin: 0 5px;
        }
        .crop-info {
            background-color: #fff3cd;
            border: 1px solid #ffeaa7;
            border-radius: 4px;
            padding: 10px;
            margin: 10px 0;
            font-size: 12px;
            color: #856404;
        }
        [data-theme="dark"] .crop-info {
            background-color: #3d3d00;
            border-color: #666600;
            color: #ffeb3b;
        }
        .btn-warning {
            background-color: #FF5722;
            color: white;
        }
        .btn-warning:hover {
            background-color: #E64A19;
        }
        .btn-success {
            background-color: #4CAF50;
            color: white;
        }
        .btn-success:hover {
            background-color: #45a049;
        }
        
        /* CSS cho chức năng crop mới - với handles */
        .crop-container-wrapper {
            position: relative;
            display: inline-block;
            margin: 20px 0;
        }
        
        /* Crop wrapper với overlay chỉ trong ảnh */
        .crop-wrapper {
            position: relative;
            display: inline-block;
            overflow: hidden;
        }
        
        .crop-wrapper::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: rgba(0, 0, 0, 0.3);
            pointer-events: none;
            z-index: 1;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .crop-active .crop-wrapper::before {
            opacity: 1;
        }
        
        .crop-selection {
            z-index: 2;
            position: absolute;
            border: 2px solid #FF5722;
            background-color: transparent;
            cursor: move;
            min-width: 50px;
            min-height: 50px;
            top: 20%;
            left: 20%;
            width: 60%;
            height: 60%;
            box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
        }
        
        /* Tạo hiệu ứng "cắt" overlay tại vùng chọn */
        .crop-selection::before {
            content: '';
            position: absolute;
            top: -2px;
            left: -2px;
            right: -2px;
            bottom: -2px;
            box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
            pointer-events: none;
            z-index: -1;
        }
        
        .crop-active .crop-wrapper::before {
            opacity: 0;
        }
        
        .crop-handle {
            position: absolute;
            background-color: #FF5722;
            border: 2px solid white;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            box-shadow: 0 2px 4px rgba(0,0,0,0.3);
            transition: background-color 0.2s ease;
            z-index: 10;
        }
        
        /* Corner handles */
        .crop-handle-nw {
            top: -6px;
            left: -6px;
            cursor: nw-resize;
        }
        
        .crop-handle-ne {
            top: -6px;
            right: -6px;
            cursor: ne-resize;
        }
        
        .crop-handle-sw {
            bottom: -6px;
            left: -6px;
            cursor: sw-resize;
        }
        
        .crop-handle-se {
            bottom: -6px;
            right: -6px;
            cursor: se-resize;
        }
        
        /* Edge handles */
        .crop-handle-n {
            top: -6px;
            left: 50%;
            transform: translateX(-50%);
            cursor: n-resize;
        }
        
        .crop-handle-s {
            bottom: -6px;
            left: 50%;
            transform: translateX(-50%);
            cursor: s-resize;
        }
        
        .crop-handle-w {
            top: 50%;
            left: -6px;
            transform: translateY(-50%);
            cursor: w-resize;
        }
        
        .crop-handle-e {
            top: 50%;
            right: -6px;
            transform: translateY(-50%);
            cursor: e-resize;
        }
        
        .crop-move-handle {
            position: absolute;
            top: 15px;
            left: 15px;
            right: 15px;
            bottom: 15px;
            cursor: move;
            background-color: rgba(255, 87, 34, 0.1);
            border: 1px dashed rgba(255, 87, 34, 0.5);
            border-radius: 4px;
            z-index: 5;
        }
        
        .crop-move-handle::before {
            content: 'Drag to move';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            font-size: 11px;
            color: #FF5722;
            font-weight: bold;
            text-shadow: 0 1px 2px rgba(255,255,255,0.8);
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .crop-move-handle:hover::before {
            opacity: 1;
        }
        
        .crop-handle:hover {
            background-color: #E64A19;
        }
        
        .crop-handle:active {
            background-color: #D84315;
        }
        
        [data-theme="dark"] .crop-selection {
            border-color: #FF7043;
            box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
        }
        
        [data-theme="dark"] .crop-selection::before {
            box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
        }
        
        [data-theme="dark"] .crop-handle {
            background-color: #FF7043;
            border-color: #333;
        }
        
        [data-theme="dark"] .crop-move-handle {
            background-color: rgba(255, 112, 67, 0.1);
            border-color: rgba(255, 112, 67, 0.5);
        }
        
        [data-theme="dark"] .crop-move-handle::before {
            color: #FF7043;
            text-shadow: 0 1px 2px rgba(0,0,0,0.8);
        }
    </style>
    <script src="jspdf.min.js"></script>
    <script src="languages.js"></script>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1 id="page-title">Screenshot Results</h1>
            <button id="language-toggle-result" class="language-toggle-result">🇺🇸 EN</button>
            <button id="theme-toggle" class="theme-toggle">Dark</button>
        </div>
        
        <div class="content">
            <div id="info-section" class="info">
                <strong id="info-label">Information:</strong> <span id="info-text">Image has been successfully captured from the current webpage.</span>
            </div>
            
            <div class="main-layout">
                <div class="image-section">
                    <div id="image-container" class="image-container">
                        <!-- Images will be added here by JavaScript -->
                    </div>
                </div>
                
                <div class="sidebar">
                    <div class="controls">
                        <div class="form-group">
                            <label for="filename" id="filename-label">File name:</label>
                            <input type="text" id="filename" placeholder="Enter new filename" value="">
                        </div>
                        
                        <div class="form-group">
                            <label for="file-format" id="format-label">File format:</label>
                            <select id="file-format">
                                <option value="png" id="format-png">PNG (High quality, transparent)</option>
                                <option value="jpg" id="format-jpg">JPG (Smaller size)</option>
                                <option value="webp" id="format-webp">WebP (Web optimized)</option>
                                <option value="pdf" id="format-pdf">PDF (Portable document)</option>
                            </select>
                        </div>
                        
                        <div class="form-group">
                            <label for="save-location" id="location-label">Save location:</label>
                            <div style="display: flex; gap: 10px; align-items: center;">
                                <input type="text" id="save-location" placeholder="Default Downloads folder" readonly style="flex: 1; background-color: var(--input-bg);">
                                <button id="choose-location-btn" class="btn btn-info" style="white-space: nowrap;">Choose location</button>
                            </div>
                        </div>
                        
                        <!-- Crop Controls -->
                        <div class="crop-section">
                            <h3 id="crop-title">Crop image</h3>
                            <div id="crop-controls" class="crop-controls-sidebar">
                                <button id="crop-enable" class="btn btn-warning">Enable crop mode</button>
                                <div id="crop-tools" class="crop-tools" style="display: none;">
                                    <div class="crop-info-sidebar">
                                        <div id="crop-dimensions-sidebar" style="font-size: 11px; color: var(--text-color); margin-bottom: 10px;">
                                            Select area to crop on image
                                        </div>
                                    </div>
                                    <div class="button-group-vertical">
                                        <button id="crop-reset-sidebar" class="btn btn-secondary btn-small">Reset</button>
                                        <button id="crop-apply-sidebar" class="btn btn-success btn-small">Apply</button>
                                        <button id="crop-disable" class="btn btn-warning btn-small">Disable crop</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        
                        <div class="button-group" style="justify-content: center;">
                            <button id="copy-btn" class="btn btn-info" data-lang-key="copyButton">Copy</button>
                            <button id="download-btn" class="btn btn-primary">Download</button>
                            <button id="download-all-btn" class="btn btn-secondary" style="display: none;">Download all</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="result.js"></script>
</body>
</html> 